package com.yanti.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

@Getter
@AllArgsConstructor
public enum LoginTypeEnum {
    /**
     * 验证码登录，为1
     */

    VERIFICATION_CODE(1),
    /**
     * 密码登录，为2
     */
    PASSWORD(2);

    private final Integer value;

    /**
     * 根据code获取枚举对象
     * @param code code
     * @return 枚举对象
     */
    public static LoginTypeEnum valueOf(Integer code) {
        for (LoginTypeEnum loginTypeEnum : LoginTypeEnum.values()) {
            if (Objects.equals(code, loginTypeEnum.getValue())) {
                return loginTypeEnum;
            }
        }
        return null;
    }

}
